Select a column based on a value.

Поиск
Список
Период
Сортировка
От eric soroos
Тема Select a column based on a value.
Дата
Msg-id 1668721.1177515469@[4.42.179.151]
обсуждение исходный текст
Список pgsql-novice
I've got something like the following where each entry has an associated form. (a join on
entries.formNum=forms.objectNum)

create table forms (objectNum int, title text, titleField text);
create table entries (id serial, formNum int, col1 text, col2 text, ...);

Forms have two types of names, either a static name in the title column or a reference to a column name in the
titleFieldcolumn (i.e. col1, col2).  I'm looking for a way to have an embedded function pull out the title of the
entry.

In psuedo code:

entryTitle= if form.titleField is not null then entries.[form.titleField]
            else form.title

I currently just grab all the possible columns and do the work in the client, but I'd really like to be able to group
by,sort and otherwise manipulate this in the backend.   

Is there a way to do this?  Or am I goign to run up against a hard wall between code and data?

eric






В списке pgsql-novice по дате отправления:

Предыдущее
От: János Löbb
Дата:
Сообщение: test geometry ... FAILED
Следующее
От: "Mark Wilson"
Дата:
Сообщение: Re: Select a column based on a value.